DocuGenerate provides secure access to its API through the use of API keys, which allow developers to access and integrate the DocuGenerate platform into their own applications.
You can get your API key from the Settings page. To authenticate, the API key needs to be included in all API requests to the server in a header that looks like this:
Authorization: <API Key>
Templates are the building blocks of DocuGenerate, providing a way to generate high-quality documents with consistent formatting. With templates, you can define the structure of your documents once and then use them repeatedly to generate new documents as needed.
To create a new template, you need to send a POST request to https://api.docugenerate.com/v1/template
with the file
parameter referencing the template file. Make sure to use multipart/form-data
as the content type when making the request.
DocuGenerate will respond with a JSON
object containing the template's properties, including for example the list of detected tags.
curl -X 'POST' \
'https://api.docugenerate.com/v1/template' \
-H 'accept: application/json' \
-H 'Authorization: 491c000c5fad32ed7787005b0723ad55' \
-H 'Content-Type: multipart/form-data' \
-F 'file=@Business Letter.docx;type=application/vnd.openxmlformats-officedocument.wordprocessingml.document' \
-F 'name=Business Letter' \
-F 'delimiters={
"left": "[",
"right": "]"
}'
{
"tags": {
"invalid": [],
"valid": [
"Name",
"Job Title",
"Company Name",
"Street Address",
"City",
"State",
"Zip Code",
"Email",
"Phone"
]
},
"filename": "Business Letter.docx",
"preview_uri": "https://storage.googleapis.com/docugenerate.appspot.com/templates/2U3i8x8vSsf7BZigyrun/Business%20Letter.pdf?GoogleAccessId=firebase-adminsdk-4i7q5%40docugenerate.iam.gserviceaccount.com&Expires=1834425197&Signature=Nwez7H3tG48u%2FFM1DTGrBv5%2Bz0746NaSajIIdQFx1EWVlv%2B3mGPAqDojW6sGhuiRB9d2vBw19HJOExcDD67nF5ccMICoQ2zHIVdrkOtVktiWB0Vhto2%2FzBbUi13XUENxRYKRAHwS21ap5O%2F1IuHd80i15VskuZJUlDxm1Jvr9Ey6eQk2Oq7%2BhhK8y8hdYtnR5hkG73XVJ1N3cci03BHbbbARyAsPU%2FHDZ5qZBh5W%2BPeqrUVnAh%2FHfZaz9UW%2BrViDa99AaKYVEpxgxnQjREu9EQyDhrk3Y2FCyn%2FfvvXES%2FSeAGzkzE%2Bkn8vRIs%2F8V5lOTLwDG7CUBrbhq2v5KFA7vw%3D%3D",
"created": 1676745185608,
"format": ".docx",
"image_uri": "https://storage.googleapis.com/docugenerate.appspot.com/templates/2U3i8x8vSsf7BZigyrun/Business%20Letter.png?GoogleAccessId=firebase-adminsdk-4i7q5%40docugenerate.iam.gserviceaccount.com&Expires=1834425197&Signature=c45AG5t468%2B05dwLrUJ3efJWP7fzzi%2BcLff%2FMuIfL5Q%2Bqg%2F6POSjIj2EvAtQB46USBtx%2BK79puLhKJCkyv2AUrrHPA2rIlZs6kqJ0lPHhv6a%2BlgpykojzR4CrBrB3mBs7HedqNRAJQNzGoLapzbk3JLJ0ynSIeEuFJU%2Bb6NChCImSm3lJUmO4Y%2FCyxw5zwSGhezRVJQsxHARu9pQKMd1qF46PoXCdvhsDdQ1wpjtFEWXvc40uuS9HZhV2TWAwOs955m%2FPsW56XriTM9o7AXV5Qyue%2B6rHd2km4GfXJl6gXepQg8TwlMXlui%2BTKuCtQM4LqQ65Nbw%2B7zKnDyRt3rlSQ%3D%3D",
"page_count": 1,
"name": "Business Letter",
"delimiters": {
"left": "[",
"right": "]"
},
"template_uri": "https://storage.googleapis.com/docugenerate.appspot.com/templates/2U3i8x8vSsf7BZigyrun/Business%20Letter.docx?GoogleAccessId=firebase-adminsdk-4i7q5%40docugenerate.iam.gserviceaccount.com&Expires=1834425197&Signature=0BiYDrrDY7AUQL%2FtolsEWb6qyJithGI1olybTvYt8w6FdxHASXmIMd%2BSbiWdd8rqEG6Pp9wm12lwp%2FsEwfpXAJ4msp2wuHOkRFmWsw8fuoJNIP5zivitr9JvGY8q%2FWOLXdVl7qjei0pE8oI6A8gZB%2Bhx3OI3S3YHXt0kA8emEOM%2B2agrY57mKHp2UuTLDcQYdOlkQ8H0oQy984UvGtSHzDRCbu7h%2BHN9kX0Nkwb72pb5vBW33kIAbFnIO1cYRDjnGhcbCf6NHFjDuxwHzsR7XMmTCwRF8CcYGF49WgSke38oM1X9mNLP%2BmT5oKQW2SJPK0qrAz8dOq%2BEVtjh%2BX9s8Q%3D%3D",
"id": "2U3i8x8vSsf7BZigyrun"
}
You generate documents by sending a POST request to https://api.docugenerate.com/v1/document
with the template_id
and data
parameters. Either the multipart/form-data
or application/json
content type can be used.
The data
parameter should be a JSON
array with values for merging and creating documents from the template, as you can see in the example below. For each object in the array, a document will be generated by replacing the merge tags with the object's values.
[
{
"Name": "Phip Crowch",
"Job Title": "Help Desk Operator",
"Company Name": "Ortiz Group",
"Street Address": "2971 Tomscot Avenue",
"City": "Annapolis",
"State": "Maryland",
"Zip Code": "21405",
"Email": "pcrowch0@disqus.com",
"Phone": "(443) 3819199"
}
]
Other parameters like output_name
, output_format
, single_file
and page_break
can be specified to fine-tune the document generation.
curl -X 'POST' \
'https://api.docugenerate.com/v1/document' \
-H 'accept: application/json' \
-H 'Authorization: 491c000c5fad32ed7787005b0723ad55' \
-H 'Content-Type: multipart/form-data' \
-F 'template_id=2U3i8x8vSsf7BZigyrun' \
-F 'data=[{"Name":"Phip Crowch","Job Title":"Help Desk Operator","Company Name":"Ortiz Group","Street Address":"2971 Tomscot Avenue","City":"Annapolis","State":"Maryland","Zip Code":"21405","Email":"pcrowch0@disqus.com","Phone":"(443) 3819199"}]' \
-F 'file=' \
-F 'sheet=' \
-F 'name=' \
-F 'output_name=' \
-F 'output_format=.pdf' \
-F 'single_file=true' \
-F 'page_break=false'
DocuGenerate will respond with a JSON
object containing the document's properties, including document_uri
that points to the URL to the generated document. The output_format
of the generated document can be .docx
, .pdf
, .doc
, .odt
or .txt
. It's worth noting that the processing time is fastest for .docx
format. For other formats, an extra conversion step is required, which increases the overall response time.
{
"document_uri": "https://storage.googleapis.com/docugenerate.appspot.com/documents/yWlzXtLmlyeaSCN2FKpt/Business%20Letter.pdf?GoogleAccessId=firebase-adminsdk-4i7q5%40docugenerate.iam.gserviceaccount.com&Expires=1719220606&Signature=kvbGRhmew7L94XlKeSnr%2F9xlboJyKgcqAt9hZnOav1ckgPeOdLxTWeBajYhWpwJBJjGfwb7ctm4iYgAYKfcqShCs6upJ9nRuQVUrODyUW%2FLRuQwawcpR2qOzr03kviZJzg9rKxY8Somg%2FW%2FfQu%2FLDtzJXkiD53IlAHdaXg9VLqrOUuxO7m5JRwBuZVcCLmLqOlFituBQcghPloq5CF2VTSjHU4HXYZLF21ST1bdXtQJfsscSqHcHB%2FhZKj2jhbj9SX6612jdMGzaHOltKN8H2CehXAlYnBWvgOFxroqEza7Bx1D69%2FVZAlRH584CeI%2Bkh27KA0%2FqNZQzNtmV70%2B3sg%3D%3D",
"created": 1687684598593,
"data_length": 1,
"template_id": "2U3i8x8vSsf7BZigyrun",
"name": "Business Letter",
"filename": "Business Letter.pdf",
"format": ".pdf",
"id": "yWlzXtLmlyeaSCN2FKpt"
}
You can find a comprehensive list of all available endpoints, including information about the request body parameters and the response schemas on the API Reference page.
These endpoints are the foundation of the DocuGenerate platform, providing a comprehensive set of tools for managing templates
and documents
. By leveraging these resources, you can easily build robust document generation workflows that can be customized to meet the specific needs of your organization.
In case you have any questions about using DocuGenerate's API, you'll find a wealth of resources in our Developers Help Center. It contains essential articles that will help you seamlessly integrate our API into your applications.
We highly recommend consulting the Test the API using Postman and Test the API using the API Reference articles for step-by-step instructions to help you get started with testing the API effectively.